package com.lw.lost.daos

import android.content.ContentValues
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase

class FeedbackDao(private val db: SQLiteDatabase) {
    
    fun insert(userId: Long, content: String): Long {
        val values = ContentValues().apply {
            put("userId", userId)
            put("content", content)
        }
        return db.insert("feedbacks", null, values)
    }

    fun getAllFeedbacks(): Cursor {
        return db.query(
            "feedbacks",
            null,
            null,
            null,
            null,
            null,
            "feedbackTime DESC"
        )
    }

    fun updateStatus(feedbackId: Long, status: Int): Int {
        val values = ContentValues().apply {
            put("status", status)
        }
        return db.update("feedbacks", values, "feedbackId = ?", arrayOf(feedbackId.toString()))
    }
} 